class Person:
    def __init__(self):
        self.list = []
    def add(self):
        pname = input("请输入您要添加的好友")
        self.list.append(pname)
        print("好友添加成功")
    def update(self):
        if len(self.list) == 0:
            print('好友列表为空')
        else:
            before_name = input("请输入要修改的好友姓名：")
            after_name = input("请输入修改后的好友姓名：")
            if before_name in self.list:
                friend_index = self.list.index(before_name)
                self.list[friend_index] = after_name
                print("修改成功")
    #删除好友的方法
    def delete(self):
        if len(self.list) != 0:
            del_name = input("请输入删除好友姓名：")
            # 删除的好友未分组
            if del_name in self.list:
                self.list.remove(del_name)
                print('删除成功')

    def find(self):
        print(self.list)

    def welcome(self):
        print("* * 欢迎使用好友管理系统 * * ")
        print("1：添加好友")
        print("2：删除好友")
        print("3：修改好友")
        print("4：展示好友")
        print("5：好友分组")
        print("6：退出")
        while True:
            option = input("请输入您需要的功能\n")
            if(option == '1'):
                self.add()
            elif(option =='2'):
                self.update()
            elif(option =='3'):
                self.delete()
            elif(option =='4'):
                self.find()
            elif(option =='6'):
                break


if __name__ == '__main__':
    p = Person()
    p.welcome()
